package query

import "fmt"

// GPUInfo 存储GPU信息
type GPUInfo struct {
	Index       int
	Utilization int
	MemoryUsed  int
	MemoryTotal int
}

// GPUQuery 定义GPU查询接口
type GPUQuery interface {
	Query() ([]GPUInfo, error)
}

// 查询器注册表
var queryRegistry = make(map[string]func() GPUQuery)

// RegisterQueryer 注册新的GPU查询器
func RegisterQueryer(gpuType string, factory func() GPUQuery) {
	queryRegistry[gpuType] = factory
}

// GetQueryer 获取指定类型的查询器
func GetQueryer(gpuType string) (GPUQuery, error) {
	factory, exists := queryRegistry[gpuType]
	if !exists {
		return nil, fmt.Errorf("不支持的GPU类型: %s", gpuType)
	}
	return factory(), nil
}
